<?php

use think\migration\Seeder;
use think\Db;

class PreResultSeeder extends Seeder
{

    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run()
    {
        for ($i = 0; $i <= 50; $i++) {
            $address = new \app\admin\model\PreResultModel();
            $address->save($this->faker());
        }
    }

    public function faker()
    {
        $faker = Faker\Factory::create('zh_CN');
        $talks = \app\admin\model\TalkModel::all()->column('id');
        $bats = \app\admin\model\BatMatchModel::all()->column('id');

        return [
            'talk_id' => $faker->randomElement($talks),
            'bat_id' => $faker->randomElement($bats),
            'main_score'=> mt_rand(1,10),
            'pass_score' => mt_rand(1,10),
        ];
    }
}